package ru.athena.runTool.Model;

import java.io.ByteArrayOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;

import javax.swing.JTextArea;

public class PrintStreamCapturer extends FilterOutputStream {
	private JTextArea receiver_;

	public static PrintStream getPrintStream( JTextArea in ) {
		return
	        new PrintStream( new PrintStreamCapturer(in));	
	}
	    
	public PrintStreamCapturer(JTextArea reseiver) {
		super(new ByteArrayOutputStream());
		receiver_ = reseiver;
	}

    public void write(byte b[]) throws IOException {
        String aString = new String(b);
        receiver_.append(aString);
    }

    public void write(byte b[], int off, int len) throws IOException {
        String aString = new String(b , off , len);
        receiver_.append(aString);
        
    }	

}
